/**
 *  \file   timers.h
 *  \author Miora ANDRIAMANOHARISOA, Loic MINGHETTI
 *  \date   PFE 2011
 *  \desc	Set up timers and periodic interuptions 
 **/
 
 
#include <msp430x22x4.h>

#ifndef APP_TIMER_H
#define APP_TIMER_H

/* TIMER FREQUENCY = 10 Hz */
#define TIMER_PERIOD_MS 100

/* Define new timers here */
#define TIMER_PREAMBULE timers[0]
#define TIMER_CAPTURE timers[1]
#define TIMER_ANTIBOUNCING timers[2]
#define TIMER_GENERATE timers[3]
#define TIMER_TX timers[4]
#define TIMER_RX timers[5]
#define TIMER_LED timers[6]
#define TIMER_LPM timers[7]

#define NUM_TIMERS 8


typedef void (*timer_watch_cb)(void);
extern uint16_t timers[NUM_TIMERS];

// register a callback to be called on timer exprire
void timer_watch (uint16_t* p_timer, timer_watch_cb cb, uint16_t count);
void timer_unwatch (uint16_t* p_timer);
void timer_reset (uint16_t* p_timer);
/** 
	* 	\fn int timer_reached(uint16_t timer, uint16_t count)
	* 	\brief fonction vérifiant l'atteinte d'une valeur seuil par un timer 
	* 	\param uint16_t timer entier représentant la valeur du timer à surveiller  
	* 	\param uint16_t count entier représentant la valeur seuils
	* 	\return retourne un entier quand le seuil est atteint 
*/
int timer_reached(uint16_t* p_timer, uint16_t count);


void timers_init(void);

#endif

